/**
 * Copyright (c) 2010 Basil Shikin, BugStat Project
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package org.bugstat.generators.reports.generators;

import java.util.Arrays;
import java.util.List;

import org.bugstat.common.bugs.Bug;
import org.bugstat.common.reports.Report;
import org.bugstat.generators.CanGenerateReports;
import org.bugstat.generators.GeneratorsStrings;
import org.bugstat.generators.reports.ReportGeneratorBase;
import org.bugstat.generators.reports.TimedIntegerReport;

/**
 * This is a generator of number of bugs fixed report
 *
 * @author Basil Shikin
 */
@CanGenerateReports
public class FixedBugs
    extends ReportGeneratorBase
{
    private final TimedIntegerReport report;
    
    public FixedBugs()
    {
        setName( GeneratorsStrings.TEXT_FIXED_BUGS );
        setSortPriority(99 );
        
        report = new TimedIntegerReport();
        report.setName( GeneratorsStrings.TEXT_TOTAL_BUGS_FIXED );
        report.setGroup( GeneratorsStrings.TEXT_GROUP_OVERVIEW );
        report.setValueName( GeneratorsStrings.TEXT_NO_BUGS_FIXED );
    }

    @Override
    public void processBug(Bug bug)
    {
        if ( !bug.isOpen() )
        {
            report.incrementValue( currentDate );
        }
        else
        {
            report.keepCurrentValue( currentDate );
        }
    }
    
    @Override
    public List<Report> getGeneratedReports()
    {
        return Arrays.asList( (Report)report );
    }
}
